package com.example.love_margin.Mapper.configuer;

public class SearchPets {

    public String selectMany(String search_pet_class,String pet_category,String pet_varieties,String key){
        StringBuffer  sqlMap = new StringBuffer ();
        String map = "SELECT * FROM search WHERE 1=1";
        sqlMap.append(map);

        if (!"".equals(search_pet_class)&&search_pet_class!=null){
            sqlMap.append(" AND search_pet_class = ").append("'").append(search_pet_class).append("'");
        }

        if(!"".equals(pet_category)&&pet_category!=null){
            sqlMap.append(" AND pet_category = ").append("'").append(pet_category).append("'");
        }
        if (!"".equals(pet_varieties)&&pet_varieties!=null){
            sqlMap.append(" AND pet_varieties = ").append("'").append(pet_varieties).append("'");
        }
        if (!"".equals(key)&&key!=null){
            sqlMap.append(" AND CONCAT(search_pet_name,search_pet_varieties,search_pet_area,search_pet_message) LIKE '%").append(key).append("%'");
        }
//        System.out.println(sqlMap);
        return sqlMap.toString();
    }

}
